<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是系统烧写——创建一个img文件烧写到sd卡中的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-06-系统烧写-02-img镜像文件">
<meta property="og:url" content="https://sumumm.github.io/post/6dad760f.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是系统烧写——创建一个img文件烧写到sd卡中的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112222116357.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241110172120026.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112222622058.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223124738.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223525481.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223603145.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223922385.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112225756009.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112225833253.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113075040753.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230006270.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232304325.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113190543343.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113190638678.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230925392.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230827387.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231016227.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113191522225.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113191859111.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231152529.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231259367.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231412768.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113075659755.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231628700.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231822209.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232017363.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232428538.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113205706699.png">
<meta property="article:published_time" content="2024-11-19T15:38:45.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.047Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV05-系统镜像">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112222116357.png">


<link rel="canonical" href="https://sumumm.github.io/post/6dad760f.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/6dad760f.html","path":"post/6dad760f.html","title":"LV05-06-系统烧写-02-img镜像文件"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-06-系统烧写-02-img镜像文件 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6"><span class="nav-text">一、img镜像文件</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BB%80%E4%B9%88%E6%98%AF%E7%A3%81%E7%9B%98%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6%EF%BC%9F"><span class="nav-text">1. 什么是磁盘镜像文件？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%B8%B8%E8%A7%81%E7%A3%81%E7%9B%98%E9%95%9C%E5%83%8F%E6%A0%BC%E5%BC%8F"><span class="nav-text">2. 常见磁盘镜像格式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-ISO%E9%95%9C%E5%83%8F%E6%A0%BC%E5%BC%8F"><span class="nav-text">2.1 ISO镜像格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-BIN-%E5%92%8C-CUE-%E9%95%9C%E5%83%8F%E6%A0%BC%E5%BC%8F"><span class="nav-text">2.2 BIN 和 CUE 镜像格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-IMG-%E9%95%9C%E5%83%8F%E6%A0%BC%E5%BC%8F"><span class="nav-text">2.3 IMG 镜像格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-%E4%B8%89%E7%A7%8D%E6%A0%BC%E5%BC%8F%E5%AF%B9%E6%AF%94"><span class="nav-text">2.4 三种格式对比</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E8%BF%99%E9%87%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E7%94%A8img"><span class="nav-text">3. 这里为什么用img</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-imx6ull%E7%9A%84img%E9%95%9C%E5%83%8F%E5%88%86%E5%8C%BA"><span class="nav-text">4. imx6ull的img镜像分区</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%88%B6%E4%BD%9Cimg%E6%96%87%E4%BB%B6"><span class="nav-text">二、制作img文件</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%AE%89%E8%A3%85%E5%B7%A5%E5%85%B7"><span class="nav-text">1. 安装工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%87%86%E5%A4%87%E6%96%87%E4%BB%B6"><span class="nav-text">2. 准备文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%88%9B%E5%BB%BA%E5%B7%A5%E4%BD%9C%E7%9B%AE%E5%BD%95"><span class="nav-text">2.1 创建工作目录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%87%86%E5%A4%87%E6%96%87%E4%BB%B6"><span class="nav-text">2.1 准备文件</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%BC%80%E5%A7%8B%E5%88%B6%E4%BD%9Cimg%E6%96%87%E4%BB%B6"><span class="nav-text">3. 开始制作img文件</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E5%88%9B%E5%BB%BA%E7%A9%BA%E7%99%BDing%E6%96%87%E4%BB%B6"><span class="nav-text">3.1 创建空白ing文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E5%AF%B9img%E6%96%87%E4%BB%B6%E5%88%86%E5%8C%BA"><span class="nav-text">3.2 对img文件分区</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-1-parted%E5%91%BD%E4%BB%A4%E7%AE%80%E4%BB%8B"><span class="nav-text">3.2.1 parted命令简介</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-2-parted%E5%91%BD%E4%BB%A4%E8%AF%B4%E6%98%8E"><span class="nav-text">3.2.2 parted命令说明</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-3-%E9%9D%9E%E4%BA%A4%E4%BA%92%E6%96%B9%E5%BC%8F%E5%88%86%E5%8C%BA"><span class="nav-text">3.2.3 非交互方式分区</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#3-2-3-1-%E5%AD%97%E8%8A%82%E4%B8%BA%E5%8D%95%E4%BD%8D%E7%9A%84%E7%A4%BA%E4%BE%8B"><span class="nav-text">3.2.3.1 字节为单位的示例</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3-2-1-2-%E6%89%87%E5%8C%BA%E7%A4%BA%E4%BE%8B"><span class="nav-text">3.2.1.2 扇区示例</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-4-parted%E5%91%BD%E4%BB%A4%E4%BA%A4%E4%BA%92%E6%96%B9%E5%BC%8F"><span class="nav-text">3.2.4 parted命令交互方式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-2-5-fdisk%E5%91%BD%E4%BB%A4"><span class="nav-text">3.2.5 fdisk命令</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E7%83%A7%E5%86%99uboot"><span class="nav-text">3.3 烧写uboot</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E5%B0%86img%E6%96%87%E4%BB%B6%E8%99%9A%E6%8B%9F%E6%88%90%E5%9D%97%E8%AE%BE%E5%A4%87"><span class="nav-text">3.4 将img文件虚拟成块设备</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-4-1-losetup%E5%91%BD%E4%BB%A4"><span class="nav-text">3.4.1 losetup命令</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-4-2-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="nav-text">3.4.2 常用命令</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-4-3-%E8%99%9A%E6%8B%9F%E6%88%91%E4%BB%AC%E7%9A%84img%E6%96%87%E4%BB%B6"><span class="nav-text">3.4.3 虚拟我们的img文件</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-%E5%88%9B%E5%BB%BA%E8%99%9A%E6%8B%9F%E7%9A%84%E5%9D%97%E8%AE%BE%E5%A4%87%E5%88%86%E5%8C%BA%E6%98%A0%E5%B0%84"><span class="nav-text">3.5 创建虚拟的块设备分区映射</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-5-1-kpartx%E5%91%BD%E4%BB%A4%E7%AE%80%E4%BB%8B"><span class="nav-text">3.5.1 kpartx命令简介</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-5-2-%E5%88%9B%E5%BB%BA%E8%99%9A%E6%8B%9F%E5%9D%97%E8%AE%BE%E5%A4%87%E5%88%86%E5%8C%BA%E6%98%A0%E5%B0%84"><span class="nav-text">3.5.2 创建虚拟块设备分区映射</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-6-%E6%A0%BC%E5%BC%8F%E5%8C%96%E5%88%86%E5%8C%BA"><span class="nav-text">3.6 格式化分区</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-7-%E5%86%99%E5%85%A5%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">3.7 写入相关文件</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#3-7-1-%E6%8C%82%E8%BD%BD%E5%88%86%E5%8C%BA"><span class="nav-text">3.7.1 挂载分区</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-7-2-%E6%8B%B7%E8%B4%9Dkernel%E3%80%81dtb%E5%92%8Crootfs"><span class="nav-text">3.7.2 拷贝kernel、dtb和rootfs</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-7-3-%E5%8D%B8%E8%BD%BD%E5%88%86%E5%8C%BA"><span class="nav-text">3.7.3 卸载分区</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-8-%E5%8D%B8%E8%BD%BD%E8%BF%98%E5%8E%9F%E8%99%9A%E6%8B%9F%E5%88%86%E5%8C%BA"><span class="nav-text">3.8 卸载还原虚拟分区</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E7%83%A7%E5%86%99%E5%88%B0SD%E5%8D%A1"><span class="nav-text">三、烧写到SD卡</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-ubuntu"><span class="nav-text">1. ubuntu</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-windows"><span class="nav-text">2. windows</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/6dad760f.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-06-系统烧写-02-img镜像文件 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-06-系统烧写-02-img镜像文件
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-11-19 23:38:45" itemprop="dateCreated datePublished" datetime="2024-11-19T23:38:45+08:00">2024-11-19</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/" itemprop="url" rel="index"><span itemprop="name">LV05-系统镜像</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>8.2k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>30 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是系统烧写——创建一个img文件烧写到sd卡中的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.2的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.6.0 build-24238078</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr>    <tr>        <td align="center" rowspan="3">Linux开发板环境</td>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，使用的uboot版本为U-Boot 2019.04</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.19.71(NXP官方提供)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="3">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/v4.19.71" target="_blank">nxp-imx/linux-imx/releases/tag/v4.19.71</a></td>        <td align="left">NXP linux内核仓库tags中的v4.19.71</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.19.35_1.1.0" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.19.35_1.1.0</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.19.35_1.1.0</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr>    <tr>        <td align="center" rowspan="2">Source Code</td>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/u-boot/latest/source" target="_blank">https://elixir.bootlin.com/u-boot/latest/source</a></td>        <td align="left">uboot源码</td>    </tr></table>
              </div>
            </details>

<p>这里只是看到有一些img文件，想要尝试一下，但是最后发现其实并不比直接烧写SD卡来的块，而且做出来的img文件可能比要更大，但是在有些场景是很实用的。</p>
<h1 id="一、img镜像文件"><a href="#一、img镜像文件" class="headerlink" title="一、img镜像文件"></a><font size=3>一、img镜像文件</font></h1><h2 id="1-什么是磁盘镜像文件？"><a href="#1-什么是磁盘镜像文件？" class="headerlink" title="1. 什么是磁盘镜像文件？"></a><font size=3>1. 什么是磁盘镜像文件？</font></h2><p>磁盘镜像文件能够完整地存储一个磁盘的内容和结构，不仅适用于 CD 或 DVD，还可以用于各种存储设备，包括磁带驱动器、硬盘、固态硬盘、U 盘，甚至软盘都可以转化成磁盘镜像文件。</p>
<p>磁盘镜像文件有许多用途，包括备份、操作系统分发、虚拟化和存档等。在 Windows、Linux 和 macOS 等主流操作系统中，许多常见的磁盘镜像格式都受到原生支持。</p>
<h2 id="2-常见磁盘镜像格式"><a href="#2-常见磁盘镜像格式" class="headerlink" title="2. 常见磁盘镜像格式"></a><font size=3>2. 常见磁盘镜像格式</font></h2><p>磁盘镜像文件具有广泛的应用领域，涵盖了不同类型的存储需求，包括存档只读存储器（ROM）和专为虚拟机设计的特殊镜像格式等。目前，有大约 150 多种不同的镜像格式可供选择。尽管许多格式在功能上存在重叠，有时可以互相替代使用，但最常被使用和推荐的仍然是 ISO、BIN&#x2F;CUE 和 IMG 这几种。</p>
<h3 id="2-1-ISO镜像格式"><a href="#2-1-ISO镜像格式" class="headerlink" title="2.1 ISO镜像格式"></a><font size=3>2.1 ISO镜像格式</font></h3><p>ISO 是目前最流行的磁盘镜像格式之一，主要用于存储使用 <a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/ISO_9660">ISO 9660</a> 文件系统的光盘。它包含了从磁盘起始位置一直到末尾的所有扇区，因此 ISO 磁盘镜像文件与其复制的原始磁盘完全相同，是逐扇区的原始驱动器复制，没有进行任何压缩处理。</p>
<p>ISO 格式的核心理念是以数字方式精确复制原始光盘，然后使用生成的磁盘镜像文件来刻录出一张与原始光盘完全相同的新光盘。这使得使用 ISO 格式刻录的光盘可以成为原始光盘的完美副本，从而方便、可靠地保存和共享数据。</p>
<p>ISO 格式在 Windows、Linux 和 macOS 等主流操作系统上都受到原生支持，通常用于分发软件和操作系统。然而，它在处理音频 CD 的「复制保护」方面存在一些限制，因此不太适合用于处理音频 CD。</p>
<p>大多数公开分发的操作系统，包括 Windows 和 Linux，都以 ISO 镜像文件的形式进行共享。除了分发程序和操作系统之外，ISO 还是备份旧光盘的理想选择。这种多功能性使得 ISO 成为许多用户的首选格式。</p>
<h3 id="2-2-BIN-和-CUE-镜像格式"><a href="#2-2-BIN-和-CUE-镜像格式" class="headerlink" title="2.2 BIN 和 CUE 镜像格式"></a><font size=3>2.2 BIN 和 CUE 镜像格式</font></h3><p>BIN 和 CUE 文件看似是两种不同的磁盘镜像格式，但实际上它们是相辅相成的：</p>
<ul>
<li>BIN 文件是整个光盘的二进制副本，包含了要刻录到光盘上的数据。</li>
<li>CUE 文件是一个纯文本文件，包含定义光盘轨道设置的元数据。</li>
</ul>
<p>这种组合使得它们成为处理光盘数据的强大工具，特别适合用于保留和复制光盘内容。</p>
<p>BIN&#x2F;CUE 镜像是原始光盘的完整复制，包括了复制保护、错误校正、曲目列表、多轨道以及任何系统特定信息。这种格式能够完整保留原始光盘的所有特性，从复制保护到多轨道音频，都是原封不动的复制，使其成为备份和复制光盘的最佳选择。</p>
<p>要使用 BIN&#x2F;CUE镜像，需要同时拥有这两个文件。BIN 文件包含原始数据，CUE 文件包含组织这些数据的元信息。在大多数情况下，BIN 文件和 CUE 文件必须同时存在，特别是要将 BIN 镜像刻录到光盘上时。这种文件组合的结构允许精确地还原原始光盘的内容和结构，确保复制的准确性和完整性。</p>
<blockquote>
<p>从现有 BIN 文件生成 CUE 文件非常简单，但无法反过来从 CUE 文件生成 BIN 文件。CUE 文件只有元信息，不包含实际数据。</p>
</blockquote>
<p>BIN&#x2F;CUE 格式的设计初衷是为了克服 ISO 格式在音频「复制保护」方面的限制。它是一种强大的磁盘镜像格式，特别适用于需要维护完整性和无限制访问的应用场景。BIN 文件包含了完整的二进制数据，包括音频和数据轨道，而 CUE 文件提供了关于如何组织这些数据的详细指令。</p>
<h3 id="2-3-IMG-镜像格式"><a href="#2-3-IMG-镜像格式" class="headerlink" title="2.3 IMG 镜像格式"></a><font size=3>2.3 IMG 镜像格式</font></h3><p>IMG 格式的使用不如 ISO、BIN&#x2F;CUE 或 DMG（macOS 使用的磁盘映像格式）那么广泛。它最初是为了备份软盘而创建的，通过复制目标磁盘每个扇区的位来工作。虽然不如其他格式流行，但对于特定用途（如软盘备份）来说，IMG 格式仍然具有独特的价值。</p>
<p>除了备份软盘，IMG 格式还可以用于存储各种内容。然而，随着软盘和软驱逐渐退出历史舞台，IMG 文件的主要用途已经转向创建硬盘镜像。需要注意的是，IMG 格式生成的文件大小始终是 512 字节的整数倍，因为它遵循了软盘的 512 字节扇区大小标准。这一特性可能在处理未来高容量硬盘或固态硬盘时变得不太合适，因此在选择 IMG 格式时需要谨慎考虑其局限性。</p>
<p>IMG 文件与 ISO 文件在功能上非常相似，主要区别在于：</p>
<ul>
<li>ISO 文件只有一种标准格式</li>
<li>IMG 镜像可以是压缩或未压缩的</li>
</ul>
<p>这种灵活性使得 IMG 格式在特定情况下更具优势，用户可以根据需要选择压缩或未压缩选项。但两者在存储光盘、分发系统等方面基本相同，但 IMG 增加的压缩选项为用户提供了更多选择。</p>
<p>未经压缩的 IMG 镜像与 ISO 镜像之间的差异并不大，甚至可以直接将 <code>IMG</code> 扩展名更改为 <code>ISO</code>，它仍然可以正常工作，或者将其转换为 VHD 文件以在 VirtualBox中使用；但是，压缩过的 IMG 会删除一些元数据以减小文件大小，因此不能与 ISO 文件互换使用。这一点需要特别注意，在处理 IMG 和 ISO 格式时，需要确保正确的文件互操作性。</p>
<h3 id="2-4-三种格式对比"><a href="#2-4-三种格式对比" class="headerlink" title="2.4 三种格式对比"></a><font size=3>2.4 三种格式对比</font></h3><table>
<thead>
<tr>
<th></th>
<th>ISO 格式</th>
<th>BIN&#x2F;CUE 格式</th>
<th>IMG 格式</th>
</tr>
</thead>
<tbody><tr>
<td>扇区大小</td>
<td>2048 字节</td>
<td>4096 字节</td>
<td>512 字节</td>
</tr>
<tr>
<td>原生操作系统支持</td>
<td>是（Windows、Linux 和 macOS）</td>
<td>是</td>
<td>是</td>
</tr>
<tr>
<td>限制</td>
<td>不支持复制保护</td>
<td>无</td>
<td>不支持复制保护</td>
</tr>
<tr>
<td>最佳用途</td>
<td>备份无复制保护的光盘</td>
<td></td>
<td></td>
</tr>
<tr>
<td>分发程序和操作系统</td>
<td>备份或复制带有复制保护的光盘</td>
<td>备份或刻录光盘</td>
<td></td>
</tr>
</tbody></table>
<h2 id="3-这里为什么用img"><a href="#3-这里为什么用img" class="headerlink" title="3. 这里为什么用img"></a><font size=3>3. 这里为什么用img</font></h2><p>我们可以img文件可以简单理解为一个磁盘，可以存放二进制数据，可以进行分区，可以建立文件系统等操作。这个img文件的扇区大小刚好与SD卡扇区大小一致，也许就是这个原因吧，我们可以将uboot、kernel、dtb和rootfs做成一个img文件，然后通过工具烧录到sd卡中。</p>
<h2 id="4-imx6ull的img镜像分区"><a href="#4-imx6ull的img镜像分区" class="headerlink" title="4. imx6ull的img镜像分区"></a><font size=3>4. imx6ull的img镜像分区</font></h2><p>其实这里的镜像分区与前面我们的sd卡是一致的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112222116357.png" alt="image-20241112222116357" />

<p>也就是：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241110172120026.png" alt="image-20241110172120026" />

<p>我们就按这个来做一个img文件。</p>
<h1 id="二、制作img文件"><a href="#二、制作img文件" class="headerlink" title="二、制作img文件"></a><font size=3>二、制作img文件</font></h1><blockquote>
<p>基本步骤</p>
<p>（1）使用dd 命令，根据固件的大小建立一个合适的 img 空文件。</p>
<p>（2）对 img 文件进行分区。</p>
<p>（3）用dd命令创建烧写u-boot。</p>
<p>（4）用losetup命令将 img 文件虚拟成循环块设备 &#x2F;dev&#x2F;loopx ，并用将虚拟出的循环块设备分区并格式化。</p>
<p>（5）创建挂载点，然后建立文件系统并且 mount 上来 。</p>
<p>（6）使用文件复制命令cp将 zImage dtb rootfs 放到指定的文件系统分区 。</p>
<p>（7）取消挂载，复制文件，烧录到 SD 卡。</p>
</blockquote>
<p>注意：这里创建的时候img文件大小小和最后生成的img文件的大小好像不太一样，具体我还不清楚是为什么，后面知道了再更新吧。</p>
<h2 id="1-安装工具"><a href="#1-安装工具" class="headerlink" title="1. 安装工具"></a><font size=3>1. 安装工具</font></h2><p>下面这些工具中，好像就用到了parted和kpartx，另外两个好像没啥用，感觉不装应该也行。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get install dosfstools dump parted kpartx</span><br></pre></td></tr></table></figure>

<h2 id="2-准备文件"><a href="#2-准备文件" class="headerlink" title="2. 准备文件"></a><font size=3>2. 准备文件</font></h2><h3 id="2-1-创建工作目录"><a href="#2-1-创建工作目录" class="headerlink" title="2.1 创建工作目录"></a><font size=3>2.1 创建工作目录</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir ~/imx6ull_img</span><br><span class="line">cd ~/imx6ull_img</span><br><span class="line">mkdir BOOT   # 这个文件夹用于挂载内核的分区</span><br><span class="line">mkdir rootfs # 这个文件夹用于挂载文件系统分区</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112222622058.png" alt="image-20241112222622058" />

<h3 id="2-1-准备文件"><a href="#2-1-准备文件" class="headerlink" title="2.1 准备文件"></a><font size=3>2.1 准备文件</font></h3><p>我们需要以下文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223124738.png" alt="image-20241112223124738" />

<p>就是这里的这些：<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/imx6ull-alpha-release/tree/master/release">release · 苏木&#x2F;imx6ull-alpha-release - 码云 - 开源中国 (gitee.com)</a></p>
<h2 id="3-开始制作img文件"><a href="#3-开始制作img文件" class="headerlink" title="3. 开始制作img文件"></a><font size=3>3. 开始制作img文件</font></h2><h3 id="3-1-创建空白ing文件"><a href="#3-1-创建空白ing文件" class="headerlink" title="3.1 创建空白ing文件"></a><font size=3>3.1 创建空白ing文件</font></h3><p>我们首先创建一个空白的img文件，创建多大？我们不可能直接创建一个2G的吧，这个其实我们可以根据上面分分区起情况和文件大小计算一下。前面uboot和kernel、dtb的大小已经知道了，现在我们看一下根文件系统，我们创建个临时目录解压一下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223525481.png" alt="image-20241112223525481" />

<p>可以看到大概13M，所以就是：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223603145.png" alt="image-20241112223603145" />

<p>所以我们粗略创建一个1M+1M+70M+30M&#x3D;102M，抹个零，100M吧，后面随着各个部分增大，我们可以再创建新的：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">dd if=/dev/zero of=imx6ull-sys.img bs=1024 count=102400 &amp;&amp; sync</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112223922385.png" alt="image-20241112223922385" />

<figure class="highlight txt"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">if=文件名：输入文件名，默认为标准输入。即指定源文件。</span><br><span class="line">of=文件名：输出文件名，默认为标准输出。即指定目的文件。</span><br><span class="line">bs=bytes：同时设置读入/输出的块大小为bytes个字节。这里也可以是1K，1M等，主要是计算大小用。</span><br><span class="line">count=blocks：仅拷贝blocks个块，块大小等于1 bs(一次读入bytes个字节，)指定的字节数。</span><br><span class="line">/dev/zero:“零”设备，可以无限的提供空字符（0x00，ASCII代码NUL）。</span><br></pre></td></tr></table></figure>

<p>到这里我们的空镜像文件就已经创建好了。可以看到创建的文件大小为100M。</p>
<h3 id="3-2-对img文件分区"><a href="#3-2-对img文件分区" class="headerlink" title="3.2 对img文件分区"></a><font size=3>3.2 对img文件分区</font></h3><h4 id="3-2-1-parted命令简介"><a href="#3-2-1-parted命令简介" class="headerlink" title="3.2.1 parted命令简介"></a><font size=3>3.2.1 parted命令简介</font></h4><p>通常我们用的比较多的分区工具是<code>fdisk</code>命令，但由于<code>fdisk</code>只支持MBR分区，MBR分区表最大支撑2T的磁盘，所以无法划分大于2T的分区。而<code>parted</code>工具可以划分单个分区大于2T的GPT格式的分区，也可以划分普通的MBR分区。</p>
<p>parted命令是由GNU组织开发的一款功能强大的磁盘分区和分区大小调整工具。parted在使用过程中有两种方式，一种是直接以非交互的方式，一种是像fdisk一样进入菜单界面进行操作。</p>
<h4 id="3-2-2-parted命令说明"><a href="#3-2-2-parted命令说明" class="headerlink" title="3.2.2 parted命令说明"></a><font size=3>3.2.2 parted命令说明</font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">SYNOPSIS</span><br><span class="line">       parted [options] [device [command [options...]...]]</span><br><span class="line">       # 其实就是</span><br><span class="line">       parted [选项] [设备 [命令 [参数]...]...]</span><br></pre></td></tr></table></figure>

<p>操作命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">    parted交互命令	                            说 明</span><br><span class="line">check NUMBER	                        做一次简单的文件系统检测</span><br><span class="line">cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER	复制文件系统到另一个分区</span><br><span class="line">help [COMMAND]	                        显示所有的命令帮助</span><br><span class="line">mklabel,mktable LABEL-TYPE	            创建新的磁盘卷标（分区表） &quot;gpt&quot;, &quot;msdos&quot;等</span><br><span class="line">mkfs NUMBER FS-TYPE	                    在分区上建立文件系统</span><br><span class="line">mkpart PART-TYPE [FS-TYPE] START END	创建一个分区</span><br><span class="line">mkpartfs PART-TYPE FS-TYPE START END	创建分区，并建立文件系统</span><br><span class="line">move NUMBER START END	                移动分区</span><br><span class="line">name NUMBER NAME	                    给分区命名</span><br><span class="line">print [devices|free|list,all|NUMBER]	显示分区表、活动设备、空闲空间、所有分区</span><br><span class="line">quit	                                退出</span><br><span class="line">rescue START END	                    修复丢失的分区</span><br><span class="line">resize NUMBER START END	                修改分区大小</span><br><span class="line">rm NUMBER	                            删除分区</span><br><span class="line">select DEVICE	                        选择需要编辑的设备</span><br><span class="line">set NUMBER FLAG STATE	                改变分区标记</span><br><span class="line">toggle [NUMBER [FLAG]]	                切换分区表的状态</span><br><span class="line">unit UNIT	                            设置默认的单位</span><br><span class="line">Version	                                显示版本</span><br></pre></td></tr></table></figure>

<p>这里主要要了解两个交互命令：</p>
<ul>
<li>mklabel</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mklabel,mktable LABEL-TYPE</span><br></pre></td></tr></table></figure>

<p>这个命令是创建新的磁盘卷标（分区表）， “gpt”, “msdos”等，一般就选这个msdos就可以了。大于2T的分区的话可以用gpt。</p>
<ul>
<li>mkpart</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mkpart PART-TYPE [FS-TYPE] START END	创建一个分区</span><br><span class="line">mkpartfs PART-TYPE FS-TYPE START END	创建分区，并建立文件系统</span><br></pre></td></tr></table></figure>

<p>这个命令主要是创建分区，这里的START和END就是起始和结束的地址，他们用什么单位？我们可以看一下man手册：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">unit unit</span><br><span class="line">	Set unit as the unit to use when displaying locations and sizes, and for interpreting those given by the user when not suffixed with an explicit unit. unit  can  be  one  of  &quot;s&quot; (sectors),  &quot;B&quot;(bytes),  &quot;kB&quot;, &quot;MB&quot;, &quot;MiB&quot;, &quot;GB&quot;, &quot;GiB&quot;, &quot;TB&quot;, &quot;TiB&quot;, &quot;%&quot; (percentage of device size), &quot;cyl&quot; (cylinders), &quot;chs&quot; (cylinders, heads, sectors), or &quot;compact&quot; (megabytes for input, and a human-friendlyform for output).</span><br></pre></td></tr></table></figure>

<h4 id="3-2-3-非交互方式分区"><a href="#3-2-3-非交互方式分区" class="headerlink" title="3.2.3 非交互方式分区"></a><font size=3>3.2.3 非交互方式分区</font></h4><h5 id="3-2-3-1-字节为单位的示例"><a href="#3-2-3-1-字节为单位的示例" class="headerlink" title="3.2.3.1 字节为单位的示例"></a><font size=3>3.2.3.1 字节为单位的示例</font></h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">以大小来划分起始和结束点</span></span><br><span class="line">sudo parted imx6ull-sys.img mklabel msdos</span><br><span class="line">sudo parted imx6ull-sys.img mkpart primary fat32 1M 64M</span><br><span class="line">sudo parted imx6ull-sys.img mkpart primary ext4 64M 100%</span><br><span class="line">sync</span><br></pre></td></tr></table></figure>

<ul>
<li><p>fat32：文件系统类型为 fat32 这是内核设备树的文件系统。</p>
</li>
<li><p>1M：这个表示内核设备树扇区的起始地址（注意不是实际地址，扇区地址x扇区大小&#x3D;实际地址），这个分区紧跟在 1M 的 u-boot 空间后面。</p>
</li>
<li><p>64M：内核设备树扇区的结束地址&#x3D;扇区起始地址+扇区大小-1。</p>
</li>
<li><p>ext4 ：文件系统为 ext4，这是根文件系统的分区。</p>
</li>
<li><p>64M：文件系统的扇区起始地址。</p>
</li>
<li><p>100%为文件系统的结束地址剩余内存，也可以不填。</p>
</li>
</ul>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112225756009.png" alt="image-20241112225756009" />

<p>我们来看一下分区情况：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">parted imx6ull-sys.img print</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112225833253.png" alt="image-20241112225833253" />

<h5 id="3-2-1-2-扇区示例"><a href="#3-2-1-2-扇区示例" class="headerlink" title="3.2.1.2 扇区示例"></a><font size=3>3.2.1.2 扇区示例</font></h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">以扇区来划分起始结束点</span></span><br><span class="line">sudo parted imx6ull-sys.img mklabel msdos</span><br><span class="line">sudo parted imx6ull-sys.img mkpart primary fat32 2048s 133119s # s就表示扇区</span><br><span class="line">sudo parted imx6ull-sys.img mkpart primary ext4 133120s 100%</span><br><span class="line">sync</span><br></pre></td></tr></table></figure>

<p>划分结果如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113075040753.png" alt="image-20241113075040753" />

<h4 id="3-2-4-parted命令交互方式"><a href="#3-2-4-parted命令交互方式" class="headerlink" title="3.2.4 parted命令交互方式"></a><font size=3>3.2.4 parted命令交互方式</font></h4><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230006270.png" alt="image-20241112230006270" />

<p>这里就不演示了，按照说明进行就可以了。</p>
<h4 id="3-2-5-fdisk命令"><a href="#3-2-5-fdisk命令" class="headerlink" title="3.2.5 fdisk命令"></a><font size=3>3.2.5 fdisk命令</font></h4><p>也可以使用fdisk命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">sumu@sumu-virtual-machine:~/imx6ull_img$ fdisk imx6ull-sys.img</span><br><span class="line"></span><br><span class="line">欢迎使用 fdisk (util-linux 2.34)。</span><br><span class="line">更改将停留在内存中，直到您决定将更改写入磁盘。</span><br><span class="line">使用写入命令前请三思。</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">命令(输入 m 获取帮助)： p</span><br><span class="line">Disk imx6ull-sys.img：100 MiB，104857600 字节，204800 个扇区</span><br><span class="line">单元：扇区 / 1 * 512 = 512 字节</span><br><span class="line">扇区大小(逻辑/物理)：512 字节 / 512 字节</span><br><span class="line">I/O 大小(最小/最佳)：512 字节 / 512 字节</span><br><span class="line">磁盘标签类型：dos</span><br><span class="line">磁盘标识符：0x040d9807</span><br><span class="line"></span><br><span class="line">命令(输入 m 获取帮助)： n</span><br><span class="line">分区类型</span><br><span class="line">   p   主分区 (0个主分区，0个扩展分区，4空闲)</span><br><span class="line">   e   扩展分区 (逻辑分区容器)</span><br><span class="line">选择 (默认 p)： p</span><br><span class="line">分区号 (1-4, 默认  1): 1</span><br><span class="line">第一个扇区 (2048-204799, 默认 2048): </span><br><span class="line">Last sector, +/-sectors or +/-size&#123;K,M,G,T,P&#125; (2048-204799, 默认 204799): +64M</span><br><span class="line"></span><br><span class="line">创建了一个新分区 1，类型为“Linux”，大小为 64 MiB。</span><br><span class="line"></span><br><span class="line">命令(输入 m 获取帮助)： n</span><br><span class="line">分区类型</span><br><span class="line">   p   主分区 (1个主分区，0个扩展分区，3空闲)</span><br><span class="line">   e   扩展分区 (逻辑分区容器)</span><br><span class="line">选择 (默认 p)： p</span><br><span class="line">分区号 (2-4, 默认  2): 2</span><br><span class="line">第一个扇区 (133120-204799, 默认 133120): </span><br><span class="line">Last sector, +/-sectors or +/-size&#123;K,M,G,T,P&#125; (133120-204799, 默认 204799): </span><br><span class="line"></span><br><span class="line">创建了一个新分区 2，类型为“Linux”，大小为 35 MiB。</span><br><span class="line"></span><br><span class="line">命令(输入 m 获取帮助)： p</span><br><span class="line">Disk imx6ull-sys.img：100 MiB，104857600 字节，204800 个扇区</span><br><span class="line">单元：扇区 / 1 * 512 = 512 字节</span><br><span class="line">扇区大小(逻辑/物理)：512 字节 / 512 字节</span><br><span class="line">I/O 大小(最小/最佳)：512 字节 / 512 字节</span><br><span class="line">磁盘标签类型：dos</span><br><span class="line">磁盘标识符：0x040d9807</span><br><span class="line"></span><br><span class="line">设备             启动   起点   末尾   扇区 大小 Id 类型</span><br><span class="line">imx6ull-sys.img1        2048 133119 131072  64M 83 Linux</span><br><span class="line">imx6ull-sys.img2      133120 204799  71680  35M 83 Linux</span><br><span class="line"></span><br><span class="line">命令(输入 m 获取帮助)： w</span><br><span class="line">分区表已调整。</span><br><span class="line">正在同步磁盘。</span><br></pre></td></tr></table></figure>

<h3 id="3-3-烧写uboot"><a href="#3-3-烧写uboot" class="headerlink" title="3.3 烧写uboot"></a><font size=3>3.3 烧写uboot</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo dd if=u-boot-dtb.imx of=imx6ull-sys.img bs=1024 seek=1 conv=notrunc,sync</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232304325.png" alt="image-20241112232304325" />

<h3 id="3-4-将img文件虚拟成块设备"><a href="#3-4-将img文件虚拟成块设备" class="headerlink" title="3.4 将img文件虚拟成块设备"></a><font size=3>3.4 将img文件虚拟成块设备</font></h3><h4 id="3-4-1-losetup命令"><a href="#3-4-1-losetup命令" class="headerlink" title="3.4.1 losetup命令"></a><font size=3>3.4.1 losetup命令</font></h4><p>我们先来看一下losetup命令，主要还是查看手册。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">SYNOPSIS</span><br><span class="line">       Get info:</span><br><span class="line">            losetup [loopdev]</span><br><span class="line">            losetup -l [-a]</span><br><span class="line">            losetup -j file [-o offset]</span><br><span class="line">       Detach a loop device:</span><br><span class="line">            losetup -d loopdev...</span><br><span class="line">       Detach all associated loop devices:</span><br><span class="line">            losetup -D</span><br><span class="line">       Set up a loop device:</span><br><span class="line">            losetup [-o offset] [--sizelimit size] [--sector-size size]</span><br><span class="line">                    [-Pr] [--show] -f|loopdev file</span><br><span class="line">       Resize a loop device:</span><br><span class="line">            losetup -c loopdev</span><br></pre></td></tr></table></figure>

<p><code>losetup</code>（Loop device setup）命令在Linux操作系统中用于设置和控制循环设备。循环设备是一种伪设备，它<strong>使文件可以作为块设备进行访问</strong>。如果只给出了<code>loopdev</code>参数，那么将显示相应循环设备的状态。</p>
<p>换句话说，就是现在这里有一个文件，循环设备可以把这个文件虚拟成块设备（block device)，比如sd卡，以便模拟整个文件系统，这样用户可以将其看作是硬盘驱动器，光驱或软驱等设备，并挂入当作目录来使用。</p>
<h4 id="3-4-2-常用命令"><a href="#3-4-2-常用命令" class="headerlink" title="3.4.2 常用命令"></a><font size=3>3.4.2 常用命令</font></h4><ul>
<li>列出所有已使用的循环设备</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">losetup -a </span><br><span class="line">losetup -l</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113190543343.png" alt="image-20241113190543343" />

<ul>
<li>查找第一个未使用的循环设备</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">losetup -f</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113190638678.png" alt="image-20241113190638678" />

<ul>
<li>分离循环设备</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo losetup -d /dev/loopx</span><br></pre></td></tr></table></figure>

<ul>
<li>创建循环设备，就是将自己的文件和循环设备建立连接</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo losetup /dev/loopx loopfile</span><br></pre></td></tr></table></figure>

<h4 id="3-4-3-虚拟我们的img文件"><a href="#3-4-3-虚拟我们的img文件" class="headerlink" title="3.4.3 虚拟我们的img文件"></a><font size=3>3.4.3 虚拟我们的img文件</font></h4><p>接下来就是把我们的img文件虚拟成块设备。首先来看一下使用一个被占用的循环设备会怎么样：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo losetup /dev/loop0 imx6ull-sys.img</span><br></pre></td></tr></table></figure>

<p>这里的loop0如果被占用:</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230925392.png" alt="image-20241112230925392" />

<p>这里会显示设备或者资源繁忙，这个时候我们可以查找一下空闲的第一个循环设备：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo losetup -f</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112230827387.png" alt="image-20241112230827387" />

<p>然后我们重新虚拟一下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo losetup /dev/loop13 imx6ull-sys.img</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231016227.png" alt="image-20241112231016227" />

<h3 id="3-5-创建虚拟的块设备分区映射"><a href="#3-5-创建虚拟的块设备分区映射" class="headerlink" title="3.5 创建虚拟的块设备分区映射"></a><font size=3>3.5 创建虚拟的块设备分区映射</font></h3><p>我们刚才对img文件进行了分区，我们后面操作需要挂载分区，可是挂载的时候要有一个节点，我们来看一下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113191522225.png" alt="image-20241113191522225" />

<p>我们挂载试一下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo mount /dev/loop13 BOOT</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113191859111.png" alt="image-20241113191859111" />

<p>发现是失败的，因为我们并没有格式化，它并没有文件系统，那怎么办？就要用到kpartx这个命令啦。</p>
<h4 id="3-5-1-kpartx命令简介"><a href="#3-5-1-kpartx命令简介" class="headerlink" title="3.5.1 kpartx命令简介"></a><font size=3>3.5.1 kpartx命令简介</font></h4><p>还是先看man手册：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">SYNOPSIS</span><br><span class="line">       kpartx [-a|-d|-u|-l] [-r] [-p] [-f] [-g] [-s|-n] [-v] wholedisk</span><br></pre></td></tr></table></figure>

<p>这个命令可以从分区表创建设备映射。这个工具源自util-linux的partx，它读取指定设备上的分区表，并在检测到的分区段上创建设备映射。</p>
<h4 id="3-5-2-创建虚拟块设备分区映射"><a href="#3-5-2-创建虚拟块设备分区映射" class="headerlink" title="3.5.2 创建虚拟块设备分区映射"></a><font size=3>3.5.2 创建虚拟块设备分区映射</font></h4><p>命令格式为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo kpartx -av /dev/loopx</span><br></pre></td></tr></table></figure>

<p>这里就是：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo kpartx -av /dev/loop13</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231152529.png" alt="image-20241112231152529" />

<p>被分区后的设备节点在&#x2F;dev&#x2F;mapper&#x2F;路径下:</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls /dev/mapper/</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231259367.png" alt="image-20241112231259367" />

<h3 id="3-6-格式化分区"><a href="#3-6-格式化分区" class="headerlink" title="3.6 格式化分区"></a><font size=3>3.6 格式化分区</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo mkfs.vfat -F 32 /dev/mapper/loop13p1</span><br><span class="line">sudo mkfs.ext4 /dev/mapper/loop13p2</span><br><span class="line">sync</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231412768.png" alt="image-20241112231412768" />

<p>然后我们可以看一下格式化情况，我们直接看这个img文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">parted imx6ull-sys.img print</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113075659755.png" alt="image-20241113075659755" />

<p>这里的大小可能有点和其他图不太对应，主要是因为这时候来重新分区的。</p>
<h3 id="3-7-写入相关文件"><a href="#3-7-写入相关文件" class="headerlink" title="3.7 写入相关文件"></a><font size=3>3.7 写入相关文件</font></h3><h4 id="3-7-1-挂载分区"><a href="#3-7-1-挂载分区" class="headerlink" title="3.7.1 挂载分区"></a><font size=3>3.7.1 挂载分区</font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo mount /dev/mapper/loop13p1 BOOT</span><br><span class="line">sudo mount /dev/mapper/loop13p2 rootfs</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231628700.png" alt="image-20241112231628700" />

<h4 id="3-7-2-拷贝kernel、dtb和rootfs"><a href="#3-7-2-拷贝kernel、dtb和rootfs" class="headerlink" title="3.7.2 拷贝kernel、dtb和rootfs"></a><font size=3>3.7.2 拷贝kernel、dtb和rootfs</font></h4><ul>
<li>（1）拷贝相关文件到对应目录</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo cp zImage imx6ull-alpha-emmc.dtb BOOT</span><br><span class="line">sudo cp rootfs.tar.bz2 rootfs</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112231822209.png" alt="image-20241112231822209" />

<ul>
<li>（2）解压根文件系统</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd rootfs</span><br><span class="line">sudo tar jxf rootfs.tar.bz2</span><br><span class="line">sudo tar xf rootfs.tar</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232017363.png" alt="image-20241112232017363" />

<h4 id="3-7-3-卸载分区"><a href="#3-7-3-卸载分区" class="headerlink" title="3.7.3 卸载分区"></a><font size=3>3.7.3 卸载分区</font></h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo umount BOOT</span><br><span class="line">sudo umount rootfs</span><br></pre></td></tr></table></figure>

<h3 id="3-8-卸载还原虚拟分区"><a href="#3-8-卸载还原虚拟分区" class="headerlink" title="3.8 卸载还原虚拟分区"></a><font size=3>3.8 卸载还原虚拟分区</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo kpartx -dv /dev/loop13</span><br><span class="line">sudo losetup -d /dev/loop13</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241112232428538.png" alt="image-20241112232428538" />

<h1 id="三、烧写到SD卡"><a href="#三、烧写到SD卡" class="headerlink" title="三、烧写到SD卡"></a><font size=3>三、烧写到SD卡</font></h1><h2 id="1-ubuntu"><a href="#1-ubuntu" class="headerlink" title="1. ubuntu"></a><font size=3>1. ubuntu</font></h2><p>ubuntu下我们可以使用dd命令烧写：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo dd if=imx6ull-sys.img of=/dev/sdc conv=fsync</span><br></pre></td></tr></table></figure>

<h2 id="2-windows"><a href="#2-windows" class="headerlink" title="2. windows"></a><font size=3>2. windows</font></h2><p>windows下用这个软件：<a target="_blank" rel="noopener" href="https://sourceforge.net/projects/win32diskimager/">Win32 Disk Imager download | SourceForge.net</a>：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-06-%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99-02-img%E9%95%9C%E5%83%8F%E6%96%87%E4%BB%B6/img/image-20241113205706699.png" alt="image-20241113205706699" />



<p>这个没啥好说的，在windows下烧写这个img文件还是很快的。</p>
<blockquote>
<p>参考资料：</p>
<p><a target="_blank" rel="noopener" href="https://www.sysgeek.cn/disk-image-formats-explained/">比较 ISO、BIN&#x2F;CUE 和 IMG，常见磁盘映像文件解析 (sysgeek.cn)</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/KingRing_/article/details/121363478">制作imx6ull Linux系统的img镜像文件（emmc烧录 ）_制造 img imx6ull-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/mzy2364/article/details/113364250">制作imx6ull Linux系统的img镜像_imx6ull emmc img 生成-CSDN博客</a></p>
<p><a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44698673/article/details/127272088">shell脚本将uboot zImage 和文件系统打包成为一个img系统镜像_如何把uboot 内核 文件系统打包-CSDN博客</a></p>
</blockquote>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/6dad760f.html">LV05-06-系统烧写-02-img镜像文件</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年11月19日 - 23:38</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/6dad760f.html" title="LV05-06-系统烧写-02-img镜像文件">https://sumumm.github.io/post/6dad760f.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/" rel="tag"><i class="fa fa-tag"></i> LV05-系统镜像</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/f68c951e.html" rel="prev" title="LV05-02-U-Boot-07-uboot编译时间与版本">
                  <i class="fa fa-angle-left"></i> LV05-02-U-Boot-07-uboot编译时间与版本
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/f6996dcc.html" rel="next" title="LV05-06-系统烧写-01-shell脚本烧写系统到SD卡">
                  LV05-06-系统烧写-01-shell脚本烧写系统到SD卡 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
